package com.chixing.day11_exception;




import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/*
* 有关日期的操作
* java.util.Date   java.util.Calendar 日历
* 注册时间、下单时间、支付时间
* 毕业时间、入学时间、生日
*
*@De
*
*
* */
public class DateDemo {
    public static void main(String[] args) throws ParseException {
        Date date = new Date();
        System.out.println(date);   //当前时间

        //1970.1.1 00:00:00 --当前对象 date 相差的毫秒数
        long xx = date.getTime();

        //2002.1.6 12:00:00 000
        // 2002.1.6 13:00:00 000   (1h = 60*60*1000 ms)
        System.out.println("2022-1-2");

        //1. 比较两个日期的先后顺序
      String a = new String("2022-08-01");
      String b = new String("2022-09-01");
      System.out.println(a.compareTo(b) < 0);
        //2. 获得当前时间的年月日 时分秒
        Calendar calendar = Calendar.getInstance();
        System.out.println("当前时间的年月日时分秒" + calendar);

        System.out.println("year:" + calendar.get(Calendar.YEAR));
        System.out.println("MONTH:" + calendar.get(Calendar.MONTH+1));
        System.out.println("DAY_OF_MONTH:" + calendar.get(Calendar.DAY_OF_MONTH));

        //calendar---->Date
        Date date1 = calendar.getTime();


        //3. 将 字符串"2000-1-12" 转换成 日期对象

        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss:SSS");
        String dateStr = dateFormat.format(new Date());   //Date ---->  String
        System.out.println(dateStr);

        //String ---->  Date
        dateStr = "2000-1-12 16:22:23:450";
        DateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
        try{
            Date date3 = dateFormat1.parse(dateStr);
            System.out.println(date3);
        }catch (ParseException e){
            e.printStackTrace();
        }
        }


}

class Resume{
    String customerName;
    String customerUniversityName;
    Date universityStartTime;
    Date universityEndTime;
    Date orderCreateTime;
    Date orderUpdateTime;
    Date payTime;
}






